Skip to content

Fix Codex global RTK reference path on macOS#1002

Closed
jiemojiemo wants to merge 1 commit into
rtk-ai:developfrom
jiemojiemo:fix_macos_codex_rtk
Closed

Fix Codex global RTK reference path on macOS#1002
jiemojiemo wants to merge 1 commit into
rtk-ai:developfrom
jiemojiemo:fix_macos_codex_rtk

Conversation

@jiemojiemo

Copy link
Copy Markdown

Description:

Summary

This PR fixes a Codex global init issue on macOS where rtk init -g --codex wrote @RTK.md into ~/.codex/AGENTS.md, but Codex resolved that reference relative to the current project instead of ~/.codex. As a result, Codex could fail to find the global RTK.md when opened in another repository.

What changed

  • Update Codex global init to write the absolute ~/.codex/RTK.md path into ~/.codex/AGENTS.md
  • Keep local Codex init behavior unchanged and continue using the project-local @RTK.md reference
  • Make AGENTS.md patching migrate legacy global @RTK.md references to the new absolute-path format
  • Make Codex uninstall and config detection handle both legacy relative references and the new absolute reference
  • Update Codex documentation to describe the correct global behavior

Tests

Added and updated unit tests covering:

  • adding the RTK reference only once
  • creating a missing AGENTS.md
  • migrating inline RTK blocks
  • migrating a legacy global @RTK.md reference to an absolute path
  • removing the absolute-path reference during Codex uninstall
  • preserving uninstall idempotency

Validated with:

cargo test patch_agents_md -- --nocapture
cargo test uninstall_codex_at -- --nocapture

Why this matters

Codex global instructions should remain valid no matter which project is opened. Writing an absolute path for global Codex setup makes the configuration stable across repositories, while preserving the existing local-project workflow.

@CLAassistant

CLAassistant commented Apr 3, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Valmonzo

Valmonzo commented Apr 3, 2026

Copy link
Copy Markdown

Thx mate , wanted to do it this weekend but u are so reactive ❤️

@jiemojiemo jiemojiemo changed the base branch from master to develop April 3, 2026 15:26
@jiemojiemo jiemojiemo force-pushed the fix_macos_codex_rtk branch from df1e594 to 925100c Compare April 3, 2026 22:41
@jiemojiemo jiemojiemo force-pushed the fix_macos_codex_rtk branch from 925100c to 76709a4 Compare April 5, 2026 03:45

@em0t em0t left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on macOS with a temporary HOME and the behavior matches the PR description.

On this branch:

  • global rtk init -g --codex writes a plain absolute RTK path into ~/.codex/AGENTS.md
  • legacy global references migrate correctly
  • uninstall removes the RTK reference cleanly and stays idempotent
  • local rtk init --codex still keeps the project-local @RTK.md flow

No blockers from my side.

@aeppling

Copy link
Copy Markdown
Contributor

Thanks for the quick fix @jiemojiemo — you were one of the first to jump on issue #996 and the approach was sound at the time.

However, this PR is now outdated and we'll close it. Here's why:

1. Fix already landed in develop
The absolute-path resolution for global Codex (@{absolute_path} format) was integrated into develop as part of the issue #892 / #996 fixes. The current develop branch already has codex_rtk_md_ref(), has_rtk_reference(), run_codex_mode_with_paths(), and all associated tests — covering the same ground as this PR. This is why the branch now shows merge conflicts.

2. @ prefix difference
This PR writes the bare path (/home/user/.codex/RTK.md) whereas develop writes @/home/user/.codex/RTK.md (with the @ include prefix). The @ form is safer since it preserves Codex's file-include syntax.

3. Native Codex hooks incoming (PR #899)
The prompt-only Codex integration (AGENTS.md + RTK.md) is being superseded by a native PreToolUse hook approach in #899. That PR adds rtk hook codex, patches .codex/hooks.json, and provides a hard guardrail instead of relying on prompt-level references. Once that lands, the AGENTS.md reference format becomes secondary.

Closing this PR — thank you again for the contribution and the responsiveness on the issue. The fix is live in develop and a more robust Codex integration is on the way.

@aeppling aeppling closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants